package jgl.vajra.kingkong.bean;

import com.orhanobut.logger.Logger;

import java.util.ArrayList;
import java.util.List;

import jgl.vajra.kingkong.widget.utils.DateUtils;

public class ReservedCarTimeBean {

    public ArrayList<String> options1Items = new ArrayList<>();
    public ArrayList<List<String>> options2Items = new ArrayList<>();
    public ArrayList<List<List<String>>> options3Items = new ArrayList<>();


    public ReservedCarTimeBean(int hour, int minute ,int useCarType) {
        int dateFormatM = DateUtils.getDateFormatM();
        int dateFormatH = DateUtils.getDateFormatH() + hour;
        if (dateFormatM >= 50) {
            dateFormatH = dateFormatH + 1;
        }

        Logger.d(dateFormatM + "时间啊");

        if(useCarType==1){
            //选项1
            if (dateFormatH < 24) {
                options1Items.add("今天");
            }

            options1Items.add("明天");
            options1Items.add("后天");

            for (int i = 0; i < options1Items.size(); i++) {
                ArrayList<String> options2Items_01 = new ArrayList<>();
                List<List<String>> options3Items_01 = new ArrayList<>();

                if (dateFormatH < 24) {
                    if (i != 0) {
                        dateFormatH = 0;
                    }
                    for (int h = dateFormatH; h < 24; h++) {

                        if (h < 10)
                            options2Items_01.add("0" + h + "点");
                        else
                            options2Items_01.add(h + "点");

                        ArrayList<String> minuteList = new ArrayList<>();
                        for (int m = 0; m < 6; m++) {
                            int num = m * minute;
                            if (h == dateFormatH) {
                                if (dateFormatM >= 50) {
                                    if (num == 0)
                                        minuteList.add("0" + num + "分");
                                    else
                                        minuteList.add(num + "分");
                                } else {
                                    if (num > dateFormatM)
                                        if (num == 0)
                                            minuteList.add("0" + num + "分");
                                        else
                                            minuteList.add(num + "分");
                                }

                            } else {
                                if (num == 0)
                                    minuteList.add("0" + num + "分");
                                else
                                    minuteList.add(num + "分");
                            }
                        }
                        options3Items_01.add(minuteList);
                    }
                } else {
                    int numDateFormatH = dateFormatH - 24;

                    if (i != 0) {
                        numDateFormatH = 0;
                    }
                    for (int h = numDateFormatH; h < 24; h++) {
                        if (h < 10)
                            options2Items_01.add("0" + h + "点");
                        else
                            options2Items_01.add(h + "点");

                        ArrayList<String> minuteList = new ArrayList<>();
                        for (int m = 0; m < 6; m++) {
                            int num = m * minute;
                            if (num == 0)
                                minuteList.add("0" + num + "分");
                            else
                                minuteList.add(num + "分");
                        }
                        options3Items_01.add(minuteList);
                    }
                }

                options3Items.add(options3Items_01);
                options2Items.add(options2Items_01);
            }
        }else {
            options1Items.add("今天");
            if (dateFormatH >= 24) {
                options1Items.add("明天");
            }
            for (int i = 0; i < options1Items.size(); i++) {
                ArrayList<String> options2Items_01 = new ArrayList<>();
                List<List<String>> options3Items_01 = new ArrayList<>();

                if (dateFormatH < 24) {
                    if (i != 0) {
                        dateFormatH = 0;
                    }
                    for (int h = DateUtils.getDateFormatH(); h < dateFormatH; h++) {

                        if (h < 10)
                            options2Items_01.add("0" + h + "点");
                        else
                            options2Items_01.add(h + "点");

                        ArrayList<String> minuteList = new ArrayList<>();
                        for (int m = 0; m < 6; m++) {
                            int num = m * minute;
                            if (h == dateFormatH-hour) {
                                if (dateFormatM >= 50) {
                                    if (num == 0)
                                        minuteList.add("0" + num + "分");
                                    else
                                        minuteList.add(num + "分");
                                } else {
                                    if (num > dateFormatM)
                                        if (num == 0)
                                            minuteList.add("0" + num + "分");
                                        else
                                            minuteList.add(num + "分");
                                }

                            } else {
                                if (num == 0)
                                    minuteList.add("0" + num + "分");
                                else
                                    minuteList.add(num + "分");
                            }
                        }
                        options3Items_01.add(minuteList);
                    }
                } else {
                    int numDateFormatH = dateFormatH - 24;

                    if (i != 0) {
                        numDateFormatH = 0;
                    }
                    for (int h = numDateFormatH; h < 24; h++) {
                        if (h < 10)
                            options2Items_01.add("0" + h + "点");
                        else
                            options2Items_01.add(h + "点");

                        ArrayList<String> minuteList = new ArrayList<>();
                        for (int m = 0; m < 6; m++) {
                            int num = m * minute;
                            if (num == 0)
                                minuteList.add("0" + num + "分");
                            else
                                minuteList.add(num + "分");
                        }
                        options3Items_01.add(minuteList);
                    }
                }

                options3Items.add(options3Items_01);
                options2Items.add(options2Items_01);
            }
        }


    }

    public ArrayList<String> getOptions1Items() {
        return options1Items;
    }

    public List<List<String>> getOptions2Items() {
        return options2Items;
    }

    public List<List<List<String>>> getOptions3Items() {
        return options3Items;
    }
}
